program a24;

{$APPTYPE CONSOLE}

 var bc:array['a'..'z']of integer;
     QsBc:array['a'..'z']of integer;

 function MAX(a,b:integer):integer;
   begin
     if a>b then result := a
       else result := b;
   end;


 procedure OUTPUT(T,p:string;ofset:integer);
   begin
     writeln(T);
     while ofset >0 do begin
                        write(' ');
                        dec(ofset);
                       end;
     writeln(p);
   end;

 procedure preQsBC(p:string);
     var m,j:integer;
         i:char;
   begin
     m := length(p);
     for i:='a' to 'z' do
       QsBC[i]:=m + 1;
     for j:=1 to m do
       QsBC[p[j]]:=m - j + 1;
   end;

 procedure pre_bc(p:string);
      var i,m:integer;
          j:char;
    begin
      m := length(p);
      for j:='a' to 'z' do
        bc[j] := m;
      for i:=1 to m - 1 do
        bc[p[i]]:= m - i;// + 1;
    end;

 procedure SMITH(T,p:string);
     var n,m,i,j:integer;
   begin
     (*
     prepocessing
     *)
     pre_bc(p);
     preQsBC(p);

     (*
     sheching
     *)
     n:=length(T);
     m:=length(p);

     j:=0;
     while (j<= n - m) do
       begin
         OUTPUT(T,p,j);

         i:=1;
         while (i<=m)and(T[i+j]=p[i]) do inc(i);
         //if i >m then OUTPUT(T,p,j);
         writeln('Shift : ',MAX(bc[T[j+m]],QsBc[T[j+m+1]]));
         inc(j,MAX(bc[T[j+m]],QsBc[T[j+m+1]]));
       end;
   end;

begin
 //SMITH('gcatcgcagagagtatacagtacg','gcagagag');
 SMITH('aassasasssaaassaaaassassassssaaassasa','assaaa');
 readln;
end.
